<!DOCTYPE html>
<html><head>
<title>用户登录_login_</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet"  type="text/css" href="http://192.168.84.101:8686/maw-home/res/js/mobile/jQ.Mobi/plugins/css/jq.popup.css"  title="synergy"/>	 
<link href="../kitchensink/icons.synergy.css" rel="stylesheet" type="text/css"  title="synergy"/>
<link href="../kitchensink/jq.ui.synergy.css" rel="stylesheet" type="text/css"   title="synergy"/>
<link href="../kitchensink/ui.synergy.css" rel="stylesheet" type="text/css"  title="synergy" />
<link href="../kitchensink/iphone.css" rel="stylesheet" type="text/css"  title="synergy" />
<link rel="stylesheet"  type="text/css" href="../kitchensink/android_480_login.css" title="synergy"/>
</head>
  
	<body>
<div id="jQUi">		
	<div id="content">
		<!-- login page start -->
	  <div  id="main" class="panel" scrolling="true" data-header="loginHeader">	
  		<div class="center">
  			<span class="login_logo"></span>	
  		</div>
       
  		<div class="center">
        <form name="loginForm"  id="loginForm"  method="post">
        <table class="table_form">
        	<tr>
                <td><label for="j_username"  >用户名:</label></td>
                <td colspan="2"><input  name="j_username"   type="text" id="j_username" value="" class="hs_ui_forms" ></td>
            </tr>
            <tr>
            <td><label for="j_password"  >密 &nbsp;&nbsp;&nbsp;码:</label></td>
            <td colspan="2"><input name="j_password"  value="" id="j_password" type="password" class="hs_ui_forms" style="-webkit-text-security: disc; "/></td>
            </tr>
      
             <tr>
                <td></td>
                <td style="text-align:right"><span>记住密码</span></td>
                <td style="text-align:left">
                <input type="checkbox" value="0" id="isSave" name="isSave" data-value="0|1" class="jq-ui-slider"> 
				<label for="isSave" style="float:none" id="isSaveLabel" onclick="MawSlider.change(event)"></label></td>
            </tr>
        </table>
         
          	
          <input type="hidden"  name="token" id="token" />
          <br/>
          <button type="button" class="hs_ui_forms"   id="loginButton">登录</button>
          <input type="hidden"  name="mac" id="mac" />
          <input type="hidden"  name="token" id="token" />
          <input type="hidden"  name="os" id="os" value="android"/>
 		</form>
 
	   </div>
	  	 
	  </div>
		<!-- login page end -->
		
		<!-- setting page start -->
		<div id="setting" class="panel" data-header="settingHeader"  scrolling="no">
	     
        <button class="btn_span" style="text-align: center;" onclick="MawTool.clearWebCache()" data-hover="true">
        	个人信息删除
        </button>
        <p class="set_note">将清空应用中的全部个人信息，且不可恢复。</p>
        <button class="btn_span" style="text-align: center;" onclick=" MawTool.checkUpgrade(event)" data-hover="true">
        	版本更新检查
        </button>
	      
	      
	    
		</div>
		<!-- setting page end -->
		 
		
	</div>
	
	
 	<div id="loginHeader" class="hidden">
	    <span  onclick="MawUser.exit(event);"  class='item icon_logout backButton' data-ignore="true" ></span>
	    <h1>登录</h1>
	    <a  href="#setting"   class="item icon_set" style="float:right" id="settingIcon" ></a>
	</div>
	<div id="settingHeader"  class="hidden">
	    <a id="backButton"   class='item icon_back' ></a>
	    <h1>设置</h1>
	</div>
	
	<iframe id="loadFrame" name="loadFrame" src="" scrolling="no" style="display:none" ></iframe>
	 
	<script type="text/javascript" charset="utf-8" src="http://192.168.84.101:8686/maw-home/res/js/mobile/jQ.Mobi/jq.mobi.js"></script>
	<script src="http://192.168.84.101:8686/maw-home/res/js/mobile/jQ.Mobi/ui/jq.ui.js" type="text/javascript"></script>
	<script type="text/javascript" charset="utf-8" src="http://192.168.84.101:8686/maw-home/res/js/lab.js"></script>
	<script src="http://192.168.84.86:8888/target/target-script-min.js#anonymous"></script>]
	<script>
		$LAB
		.script('http://192.168.84.101:8686/maw-home/res/js/maw/util.js')
		.script(function(){
			var u = navigator.userAgent.toLowerCase();
			if (u.indexOf('android') > -1){
				return "http://192.168.84.101:8686/maw-home/res/js/cordova-android.js";
			}else if(u.indexOf('iphone') > -1){
				return "http://192.168.84.101:8686/maw-home/res/js/cordova-1.6.1.js";
			}	
		})
		.script("http://192.168.84.101:8686/maw-home/res/js/mobile/jQ.Mobi/plugins/jq.extend.js")
		.wait()
		.script("http://192.168.84.101:8686/maw-home/res/js/maw/plugin.js")
		.script("http://192.168.84.101:8686/maw-home/res/js/md5.js")
		.script("http://192.168.84.101:8686/maw-home/res/js/base64.js")
		.script("http://192.168.84.101:8686/maw-home/res/js/mobile/jQ.Mobi/plugins/hs.slider.js")
		.script("http://192.168.84.101:8686/maw-home/res/js/maw/notification_main.js")
		.script("http://192.168.84.101:8686/maw-home/res/js/maw/jq.ui.dialog.js")
		.wait(function(){
			jsReady();	
		});
		 
	</script>

 <script>
 
			//var webRoot="http://192.168.84.101:8686/maw-home/res/css/";
			
			$.ui.isAjaxApp=true;
			$.ui.autoLaunch=true;
		    $.ui.openLinksNewTab=false;
		   
		    var init = function(){
			   window.setTimeout(function(){$.ui.launch();},1000);
		    };
		    document.addEventListener("DOMContentLoaded",init,false);
		      
			$.ui.ready(function(){
			    console.log('ready');
			    $.ui.backButtonText="&nbsp;";  
			    $.ui.setBackButtonStyle('icon back');
			    $.ui.removeFooterMenu();
				 
			});
		   
		    /* This code prevents users from dragging the page */
		    var preventDefaultScroll = function(event) {
		        event.preventDefault();
		        window.scroll(0,0);
		        return false;
		    };
			document.addEventListener('touchmove', preventDefaultScroll, false);
		
		    /* This code is used to run as soon as appMobi activates */
		    var onDeviceReady=function(){
				AppMobi.device.setRotateOrientation("portrait");
		        AppMobi.device.setAutoRotate(false);
				//webRoot=AppMobi.webRoot+"kitchensink/";
			    //hide splash screen
			    //AppMobi.device.hideSplashScreen();	
		    };
		    document.addEventListener("appMobi.device.ready",onDeviceReady,false);  
		 
 

		if(!((window.DocumentTouch&&document instanceof DocumentTouch)||'ontouchstart' in window)){
			var script=document.createElement("script");
			script.src="http://192.168.84.101:8686/maw-home/res/js/mobile/jQ.Mobi/touch.js";
			var tag=$("head").append(script);
			$.os.android=true; //let's make it run like an android device
			$.os.desktop=true;
		}
 
  
 </script>

 
	<script>
 		  
		if(typeof loadScript !="undefined"){
			function loadScript(url, callback){
				var script = document.createElement ("script")
				script.type = "text/javascript";
				script.onload = function(){
					callback();
				};
				script.src = url;
				document.getElementsByTagName("head")[0].appendChild(script);
			}	
		}
		 
			
		var Maw = {
			"deviceReady":function(){
				MawUser.getUserFromFS(
 					function(mUser){
 						$('#j_username').val(mUser.userName);
 						$('#j_password').val(mUser.password);
 						$('#isSave').val(mUser.isSave);
 						MawSlider.init("isSave");	
 					},
 					function(){
 						alert("读取用户信息失败！");	
 					}
 				);		
			}
		};	
	  
		var jsReady = function() {
			
				$("#j_username").bind("focus",function(){
		 			$(this).addClass("inp_login_active");	
		 			var _this =$(this);
	 				setTimeout(function(){
	 					if(!_this.hasClass("inp_login_active")){
							_this.trigger("focus");
					    console.log(" focus ....");
					  }
					},500);	
		 		}).bind("blur",function(){
		 			$(this).removeClass("inp_login_active");	
		 		});
			/**
		
			
			$("#j_username").bind("focus",function(){
				setTimeout(function(){
					var theTarget = document.getElementById("j_username");
					var clickevent = document.createEvent('Event');
			    clickevent.initEvent('click', true, false);
			    theTarget.target = "_blank";
			    theTarget.dispatchEvent(clickevent);
				},2500);	
			});
 	    	
		 	***/	
		 		$("#j_password").bind("focus",function(){
		 			$(this).addClass("inp_login_active");	
		 		}).bind("blur",function(){
		 			$(this).removeClass("inp_login_active");	
		 		});
 				
				$("button").each(function(){
					if($(this).attr("data-hover")){
						var _this = $(this);

						$(this).bind("touchstart",function(e){
							_this.addClass("btn_hover");	
							e.preventDefault();
							e.stopPropagation();  
						});	
						$(this).bind("touchend",function(e){
							_this.removeClass("btn_hover");	
							e.preventDefault();
							e.stopPropagation();  
						});
				
					}
				});
				var clickable = true;
				$("#loginButton").bind("click",function(e){
					
					if(!clickable)
						return;
					clickable = false;	
					setTimeout(function(){ clickable = true; }, 1000);  
					var userName = $('#j_username').val();
					var password = $('#j_password').val();
					var isSave = 0;
					/*
					if($('#isSave').prop("checked")){
						isSave = 1;
					} 
					*/
					if($('#isSave').val() =='1'){
						isSave = 1;	
					}
					
					console.log("isSave : "+isSave + "  userName: "+ userName+"  password: "+ password+"  token: "+token+"  imei: "+imei+"  imsi: "+imsi);
				
				 	 
					if(userName ===""){
						MawNotification.alert("用户名不能为空");
						//jq("body").alert("用户名不能为空");
						return false;	
					}
					if(password ===""){
						MawNotification.alert("密码不能为空!");
						return false;	
					}
					 
					var platform = MawDevice.platform;
					var imsi = '';
					var imei = '';
					var token = '';
					if(platform == "android"){
						imsi = MawDevice.imsi;	
						imei = MawDevice.imei;
					}
					else if(platform == "ios"){
						token = $('#token').val();
						imsi = imei = token;	
					}
					var resolution = MawDevice.resolution;
					
					//alert("imsi:"+imsi +" imei: "+imei+" resolution:"+resolution);
					
					/*** login data start ***/
			 		loginData = {j_username:userName,j_password:password,token:token,imei:imei,imsi:imsi,resolution:resolution};
				  //console.log(JSON.stringify(loginData));
				 	
					loginOpts={
						type:"POST",
						dataType:"json",
						success:function(jsonObj){
							//alert(jsonObj.status);
					 		console.log(" jsonObj.status : " + jsonObj.status);
							if(jsonObj.status == "success"){
								if(isSave == 1){
									MawUser.saveUser(userName,password,isSave);		
								}else {
									MawUser.saveUser('','','0');	
								}
								var userKey =hex_md5(userName);
								var mUser = {userKey:userKey,userName:userName};
								MawUser.saveUserInfoToLocalS(mUser,function(){
									if(jsonObj.url){
										 
										var forwardUrl = Config.host + jsonObj.url;
										console.log(" forwardUrl : " + forwardUrl);
										var a = document.createElement('a');
										var clickevent = document.createEvent('Event');
									    clickevent.initEvent('click', true, false);
									    a.target = "_blank";
									    a.href = forwardUrl;
									    a.dispatchEvent(clickevent);
									}else{
										$.ui.hideMask();	
									}	
								});
								var ja = ["header",null,"showWebView",[Config.notificationUrl]];
								var json = JSON.stringify(ja);
								//alert("MPlugin:"+MPlugin);
								MPlugin.exec(json);	 
							}else if(jsonObj.status == "error"){ 
											
							}
							
							
						},
						error: function(msg){
							alert(msg+" login  error");
							$.ui.hideMask();
						},
						url: Config.loginUrl,
						data: loginData,
					}
			 		
			 		/*** login data end ***/
					
					
				  if(MawBrowser.isAndroid()){
						MawTool.checkUpgrade(e,function(){
							$.ui.showMask("登录中...");
							$.ajax(loginOpts);	
						});
			  	}else if(MawBrowser.isIPhone()){
			  		alert("is iphone");
			  		$.ui.showMask("登录中...");	
			  		$.ajax(loginOpts);
			  	}
				//var xml = '<root><enforce>false</enforce><version>2.3</version><item>http://192.168.84.101:8686/maw-home/upgrade/chineseChess.apk</item></root>'; 
 
	      });
	      
	      /* 
				$('input').focus(function(){
			    var center = $(window).height()/2;
			    var top = $(this).offset().top ;
			    if (top > center){
			        $(window).scrollTop(top-center);
			    }
				});	
				*/
				
				
				//test  
				MawPlugin.test_spwd();	 
			};
		 
	</script>
</div>	
	</body>
</html>
